<?php
/**
 * Created by Bruce.
 * IDE: PhpStorm
 * Date: 2018/8/8
 * Time: 10:01
 */

namespace app\park\model;


use think\Db;

class AdminQueryParkInfoMode
{
    private $db;

    function __construct()
    {
        $this->db = Db::connect();
    }

    public function query($openId)
    {
        $res = $this->db->table('park_info')->field('park_name,univalence,longitude,latitude,location,space')->where('open_id', $openId)->select();
        $res = $res[0];
        return $res;
    }

    public function upData($openId, array $data)
    {
        $res = $this->db->table('park_info')->where('open_id', $openId)->update($data);
        if ($res == 1) {
            return ['code' => '200', 'result' => 'update ok'];
        } else {
            return ['code' => '200', 'result' => 'update error'];
        }

    }

    function __destruct()
    {
        // TODO: Implement __destruct() method.
        if ($this->db != null) {
            $this->db->close();
        }
    }
}
